home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
vol16n12.zip
/
IPC.ZIP
/
THROW.ZIP
/
THROWDLG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-02-12
|
2KB
|
105 lines
// ThrowDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Throw.h"
#include "ThrowDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CThrowDlg dialog
CThrowDlg::CThrowDlg(CWnd* pParent /*=NULL*/)
: CDialog(CThrowDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CThrowDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadStandardIcon(IDI_WINLOGO);
}
void CThrowDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CThrowDlg)
DDX_Control(pDX, IDC_EDIT, m_wndEdit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CThrowDlg, CDialog)
//{{AFX_MSG_MAP(CThrowDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_SEND, OnSend)
//}}AFX_MSG_MAP
ON_BN_CLICKED (IDOK, OnSend)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CThrowDlg message handlers
BOOL CThrowDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
return TRUE;
}
void CThrowDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CThrowDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CThrowDlg::OnSend()
{
CString string;
m_wndEdit.GetWindowText (string);
TCHAR* pString = new TCHAR[string.GetLength () + 1];
::lstrcpy (pString, (LPCTSTR) string);
if (!string.IsEmpty ()) {
CWnd* pWnd = CWnd::FindWindow (NULL, "Catch");
if (pWnd != NULL) {
COPYDATASTRUCT cds;
cds.dwData = string.GetLength () + 1;
cds.cbData = (string.GetLength () + 1) * sizeof (TCHAR);
cds.lpData = (PVOID) pString;
pWnd->SendMessage (WM_COPYDATA, (WPARAM) m_hWnd, (LPARAM) &cds);
}
}
}